function [X,U,Kx,Kv]=adjust(A,B,C,D,E,S,J,P)
    [n,n]=size(A);
    [p,m]=size(D);
    [k,k]=size(S);
    j=jordan(S);
    [V,ddd]=eig(S);
    Phi=[A B;C D];
    Pi=[eye(n) zeros(n,m);zeros(p,n) zeros(p,m)];
    DD=[E;J]*V;
    W=zeros(n+p,k);
    W(:,1)=inv(j(1,1).*Pi-Phi)*DD(:,1);
    for i=2:k
        W(:,i)=inv(j(i,i).*Pi-Phi)*(DD(:,i)-j(i-1,i).*W(:,i-1));
    end
    W=W*inv(V);
    X=W(1:n,:);
    U=W(n+1:n+p,:);
    Kx=-place(A,B,P);
    Kv=U-Kx*X;
end